module.exports = {
  type: 'list',

  created() {
    this.actions = [
      {
        onClick: () => {
          /*
      var dkr = this
    //$input.confirm({        title: typeof(dkr)              })
$ui.showCode(typeof(dkr)+'\n'+JSON.stringify(dkr, null, '\t'))
//*/

          //$ui.toast(JSON.stringify(   ))
          if (!this.SYY) {
            this.finish()

            $router.to(
              $route('LB_liebiao', {
                title: this.args.title,
                httpDR: this.args.httpDR,
                iqqDR: this.args.iqqDR
              })
            )
          } else {
            if (this.PDXYY == null) {
              this.PDXYY = 1
              $input.confirm({
                message: '没有下一页了',
                okBtn: '确定'
              })
            }
          }
          //*/
        },

        title: '下一页'
      }
    ]
  },
  async fetch({ args, page }) {
    this.args.iqqDR++
    let res
    let LS //= 'animation'
    if (this.nextPage == null) {
      LS = args.keyword

      if (LS != null) {
        this.args.iqqDR = 1
        if (!$storage.has('搜索库')) {
          $storage.put('搜索库', 'serch_18av')
          $ui.toast('自动设置搜索库为;\n' + $storage.get('搜索库'))
        }
        $ui.toast('在库' + $storage.get('搜索库') + '里搜索\n' + LS)
        this.title = $storage.get('搜索库') + '里搜  ' + LS
        //修改标题

        this.nextPage =
          'https://' +
          $prefs.get('baseURL') +
          '/' +
          $storage.get('搜索库') +
          '/' +
          encodeURI(LS) +
          '_1.htm'
      } else {
        this.nextPage = args.httpDR
      }
    }

    ///\\\\\||||||||||\\\\\\\\\

    if (this.SYY) {
      this.nextPage = null
      //$ui.toast('到底了')
      return {
        items: [
          {
            title: '\t\t\t\t到底了',
            //列表样式
            style: 'article'
          }
        ],

        nextPage: this.nextPage
      }
    } else {
      res = await http_dh.get(this.nextPage, header_asb)
args.httpDR=this.nextPage
      //let res = await $http.get(`https://maa1804.com/serch_mvsort/%E8%99%95%E7%94%B7_${page || 1}.htm`,header_asb)

      ///\\\\\||||||||||\\\\\\\\\

      //eval("DSF_zujian."+'rr')(item.title, lsls)
      //字符串转可执行代码eval("这里面的是字符串")
      let sdf = 0
      this.title = this.args.iqqDR + '  ' + args.title
      ////////////////////

      ///\\\\\||||||||||\\\\\\\\\

      let ixa = res.data

    if (ixa.indexOf("value='同意(enter)'") != -1) {
      args.LYLY=this.route.path
      this.finish()
      $router.to($route('cookie_huoqu', args))
      
    } else {
      ///////////////////////////////////////
      if (ixa.indexOf('class="aRF_Scg"') == -1) {
        this.finish()
        $router.to($route('biaoge', {ixa: ixa, title: args.title}))
      }

      let uutt = []

      let eee = "class='pageback'><a href='(.+?)'>下一頁 >"

      let http_XYY = ixa.match(eee)

      //是否有下一页
      if (http_XYY != null) {
        this.nextPage = this.args.httpDR = encodeURI('https:' + http_XYY[1])
        //XYY_title = '下一页'
      } else {
        this.SYY = true
      }

      let nnaa = new RegExp(
        '<a class="aRF".{1,37}?href="(.{5,65}?)".{1,37}?class="aRF_Scg".{1,37}?src="(.{1,65}?)".{1,37}?alt="(.{1,154}?)"',
        'g'
      )

      let ixaqq = ixa.match(
        '<a class="aRF".{6,140}?class="aRF_Scg".{4,150}?alt="(.|\n|\r)+<a class="aRF".{6,140}?class="aRF_Scg".{4,150}?alt=".{3,400}?</a>'
      )
      if (ixaqq != null) {
        ixa = ixaqq
      }

      let items = []

      let items_aa = {
        title: '\t\t\t\t第（' + this.args.iqqDR + '）页',
        //列表样式
        style: 'article'
        /*
        ,onClick: () => {
          //$ui.toast(JSON.stringify(   ))

          this.finish()
          $router.to(
            $route('LB_liebiao', {
              title: args.title,
              httpDR: args.httpDR,
              iqqDR: args.iqqDR
            })
          )
        }
        */
      }

      items.push(items_aa)

      var liebiao_onClick = require('.//JS/liebiao_onClick.js')
      //调用当前目录的bb.js
      //循环获取和显示新的内容
      while ((uutt = nnaa.exec(ixa)) != null) {
        let LS
        //是否为xp1网页
        if (uutt[1].indexOf('/xp1/') != -1) {
          LS = false
        } else {
          LS = true
        }
        //lsls和BFQ是为onClick准备的
        let lsls = uutt
        let BFQ = LS

        items.push({
          title: uutt[3],

          //列表样式
          style: 'article',
          //大小，最多12
          spanCount: 12,
          image: uutt[2],
          onClick: item => {
            //是否为xp1网页
            if (BFQ) {
              liebiao_onClick.ee(item.title, lsls)
            } else {
              liebiao_onClick.rr(item.title, lsls)
            }
          }
        })
      }
      XYY = null
      //items.push(items_aa)
      return {
        items: items,
        nextPage: this.nextPage

        //nextPage : (page || 1)  + 1
        //nextPage: http_XYY != null ? (page || 1)  + 1 : null
      }
    }}
    ///\\\\\||||||||||\\\\\\\\\
    //return   qq(titleT, XYY_title, nnaa,ixa,this.finish)
  }
}
